package com.by.controller;

import com.by.biz.IUserBiz;
import com.by.model.Result;
import com.by.model.User;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

@RestController
public class UserController {
    @Autowired
    private IUserBiz UserBiz;

    @RequestMapping("/toList")
    public ModelAndView toList(){
        return new ModelAndView("list");
    }
    @RequestMapping("/getPage")
    public Map queryUserByPage(int pageNum, int pageSize, User user){
        Map map = new HashMap();
        map.put("pageSize",pageSize);
        map.put("pageNum",pageNum);
        map.put("user",user);
        Page page= UserBiz.queryLikeUsers(map);
        map.put("page",page);
        map.put("totalPage",page.getPages());
        return map;


    }
    @RequestMapping("/add")
public Result addUser(User user){
    UserBiz.addUser(user);
    return new Result();
}

}
